import { Column, CreateDateColumn, Entity, PrimaryGeneratedColumn, UpdateDateColumn } from "typeorm";

@Entity('test_org_closure')
export class OrgClosure {

  @PrimaryGeneratedColumn()
  id: number;

  // 组织id
  @Column({ name: 'descendant_id' })
  descendantId: number;

  // 上级组织id
  @Column({ name: 'ancestor_id' })
  ancestorId: number;

  // 层级
  @Column()
  depth: number;
}

@Entity('test_org')
export class OrgEntity {

  @PrimaryGeneratedColumn()
  id: number;

  // 组织名称
  @Column({ name: 'org_name' })
  orgName: string;

  @CreateDateColumn({ type: 'timestamp', name: 'create_time' })
  createTime: string;

  @Column({ select: false, name: 'create_user_id' })
  createUserId: number;

  @UpdateDateColumn({ select: false, name: 'update_time' })
  updateTime: string;

  @Column({ select: false, name: 'update_user_id' })
  updateUserId: number;

  @Column({ select: false })
  delete_flag: boolean;

  parentId: number;

  // 子节点数据
  children: OrgEntity[]
}